import java.beans.Expression;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;


public class TCPServer {

	
	public static void main(String[] args) throws Exception {
		String nhan;
		String gui;
		ServerSocket welcomeSocket = new ServerSocket(9999);
		System.out.println("Server lang nghe ket noi taia cong 9999.");
		while(true){
			Socket client = welcomeSocket.accept();
			BufferedReader in = new BufferedReader(new InputStreamReader(client.getInputStream()));
			DataOutputStream out = new DataOutputStream(client.getOutputStream());
			nhan = in.readLine();
			System.out.println("Da nhan tu client: "+nhan);
			gui = nhan.toUpperCase() + '\n';
			System.out.println("Gui lai Client: "+gui);
			out.writeBytes(gui);
		}
		// TODO Auto-generated method stub
		
	}

}
